package com.example.webflux.webflux.demo2;

import com.example.webflux.webflux.demo2.handler.MyHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;

/**
 *@Deacription TODO
 *@Author baohuajie
 *@Date 2020/12/30 20:52
 *@Version 1.0
 **/
@Configuration
public class RoutingConfiguration {

    @Bean
    public RouterFunction<ServerResponse> routerFunction(MyHandler myHandler) {

        RouterFunction<ServerResponse> route =
                RouterFunctions.route(RequestPredicates.POST("/demo1"), myHandler::getUserById)
                .andRoute(RequestPredicates.POST("/demo2"), myHandler::getUserByName);
        return route;
    }

}
